home *** CD-ROM | disk | FTP | other *** search
- /* EB.X V1.10
- 1995.9.3 鈴木 健児 */
-
- #include "common.h"
-
- #include <iocslib.h>
- #include <jctype.h>
- #include <method\Dos_i.h>
-
- int set_gaiji2( int , unsigned int );
- int set_gaiji1( int , unsigned int );
- int reset_gaiji( void );
- int set_gaiji_ebg( int , unsigned int );
- int reset_gaiji_ebg( void );
- int nextcode( int );
- int nextcodejis( int );
-
- static struct FNTBUF fnttbl[ 190 ]; /* 元々登録してあった外字を保存する */
- int fnttblptr;
- unsigned short f2jisst , f2jised , f2jismax;
- unsigned short f1jisst , f1jised , f1jismax;
- unsigned short f2ascst , f2asced , f2ascmax;
- unsigned char f2esc;
-
- /* char fn2[ ] = "j:\\crger\\start" ; */
- /* char fn2[ ] = "f:\\fss\\start" ; */
- /* char fn2[ ] = "j:\\jirin\\start" ; */
-
- /*
- int main(int argc, char *argv[])
- {
- unsigned short rootpagenumber;
- int code;
-
- cdfile = fopen( fn2 , "rb" );
- if( cdfile == NULL)
- {
- printf( "Error ファイルがオープンできません\n" );
- return( 0 );
- };
-
-
- rootpagenumber = search_rootindexpos2( 0xf200 );
- if( rootpagenumber == 0 )
- {
- return( 0 );
- };
- DOSSEEK( cdfile , rootpagenumber*0x800 , SEEK_SET );
- code = set_gaiji2( 0xeb9f );
- printf( "\ncode2 = %x\n" , code );
-
- DOSSEEK( cdfile , 0 , SEEK_SET );
- rootpagenumber = search_rootindexpos2( 0xf100 );
- if( rootpagenumber == 0 )
- {
- return( 0 );
- };
- DOSSEEK( cdfile , rootpagenumber*0x800 , SEEK_SET );
- code = set_gaiji1( code );
- printf( "\ncode1 = %x\n" , code );
-
- return( 0 );
- }
-
-
- unsigned short search_rootindexpos2( unsigned short target )
- {
- unsigned short saizu;
- unsigned short data;
- unsigned short retcode;
- int i;
-
- DOSREAD( cdfile , &saizu , sizeof( unsigned short ) , 1 , cdfile );
- DOSSEEK( cdfile , 16 , SEEK_SET );
-
- i = 0;
- retcode = 0;
- while( (i < saizu) && retcode == 0 )
- {
- DOSREAD( &data , sizeof( unsigned short ) , 1 , cdfile );
- printf( "data =%x\n" , data );
- if( (data & 0xff00 ) == target )
- {
- DOSSEEK( cdfile , 2 , SEEK_CUR );
- DOSREAD( &retcode , sizeof( unsigned short ) , 1 , cdfile );
- } else {
- DOSSEEK( cdfile , 14 , SEEK_CUR );
- };
- i++;
- };
-
- return( retcode );
- }
- */
-
- /* set_gaiji2()、set_gaiji1()の順でコールすること fnttblptrの関係 */
- /* 半角 f200 はこれで良いらしい 0xa121~に対応 */
- int set_gaiji2( int code , unsigned int pagenum )
- {
- int i , o , k , stat;
- int count;
- unsigned short numofgaiji;
- unsigned char bitpatan;
- unsigned char patan[ 32 ];
-
- DOSSEEK( cdfile , pagenum*0x800 , SEEK_SET );
- DOSSEEK( cdfile , 10 , SEEK_CUR );
- DOSREAD( cdfile , &f2jisst , sizeof( unsigned short ) );
- DOSREAD( cdfile , &numofgaiji , sizeof( unsigned short ) );
-
- /* 外字の終わりのコード(JIS)を得る */
- f2jised = f2jisst;
- for( count=0; count < (numofgaiji-1); count++ )
- {
- f2jised = nextcodejis( f2jised );
- };
- /* printf( "gaiji = %4x , %4x , %d\n" , f2jisst , f2jised , numofgaiji ); */
- f2jismax = f2jisst-1;
-
- DOSSEEK( cdfile , (pagenum+1)*0x800 , SEEK_SET );
-
- /* code = JISSFT( 0x7721 ); */
- i = 0;
-
- for( count=0; count<numofgaiji; count++ )
- {
- for( o=0; o<16; o++ )
- {
- DOSREAD( cdfile , &bitpatan , sizeof( unsigned char ) );
- patan[ o*2 ] = bitpatan;
- patan[ o*2+1 ] = 0;
- };
-
- stat = FNTGET( 8 , code , &fnttbl[ i ] );
- k = DEFCHR( 8 , code , patan );
- /* printf( "i=%x c=%4x %c%c : " , i , code , code >> 8 , code & 0x00ff ); */
- codetbl2[ i ] = code;
-
- f2jismax = nextcodejis( f2jismax );
- code = nextcode( code );
- if( code == -1 )
- {
- count = numofgaiji;
- puts( "外字の数が多すぎます\n" );
- };
- i++;
- };
- codetbl2[ i ] = 0xffff;
-
- /* printf( "gaijimax = %4x" , f2jismax ); */
- fnttblptr = i;
- return( code );
- }
-
- /* set_gaiji2()、set_gaiji1()の順でコールすること fnttblptrの関係 */
- /* 全角 f100 はこれで良いらしい 0xa421~に対応する */
- int set_gaiji1( int code , unsigned int pagenum )
- {
- int i , o , k , stat;
- int count;
- unsigned short numofgaiji;
- unsigned char bitpatan;
- unsigned char patan[ 32 ];
-
- DOSSEEK( cdfile , pagenum*0x800 , SEEK_SET );
- DOSSEEK( cdfile , 10 , SEEK_CUR );
- DOSREAD( cdfile , &f1jisst , sizeof( unsigned short ) );
- DOSREAD( cdfile , &numofgaiji , sizeof( unsigned short ) );
-
- /* 外字の終わりのコード(JIS)を得る */
- f1jised = f1jisst;
- for( count=0; count < (numofgaiji-1); count++ )
- {
- f1jised = nextcodejis( f1jised );
- };
- /* printf( "gaiji = %4x , %4x , %d\n" , f1jisst , f1jised , numofgaiji ); */
- f1jismax = f1jisst-1;
- DOSSEEK( cdfile , (pagenum+1)*0x800 , SEEK_SET );
-
- if( code < 0 )
- {
- return( code );
- };
-
- /* j = JISSFT( 0x7621 ); */
-
- i = 0;
- for( count=0; count<numofgaiji; count++ )
- {
- for( o= 0 ; o<32 ; o++)
- {
- DOSREAD( cdfile , &bitpatan , sizeof( unsigned char ) );
- patan[ o ] = bitpatan;
- };
- stat = FNTGET( 8 , code , &fnttbl[ i+fnttblptr ] );
- k = DEFCHR( 8 , code , patan );
- /* printf( "i=%x c=%4x:%c%c : " , i , code , code >> 8 , code & 0x00ff ); */
- codetbl1[ i ] = code;
-
- f1jismax = nextcodejis( f1jismax );
- code = nextcode( code );
- if( code == -1 )
- {
- count = numofgaiji;
- puts( "外字の数が多すぎます\n" );
- };
- i++;
- };
- codetbl1[ i ] = 0xffff;
- /* printf( "gaijimax = %4x" , f1jismax ); */
-
- return( code );
- }
-
- int reset_gaiji( void )
- {
- int i , j , stat;
-
- i = 0;
- while( codetbl2[ i ] != 0xffff )
- {
- stat = DEFCHR( 8 , codetbl2[ i ] , fnttbl[ i ].buffer );
- i++;
- };
-
- j = i;
- i = 0;
- while( codetbl1[ i ] != 0xffff )
- {
- stat = DEFCHR( 8 , codetbl1[ i ] , fnttbl[ i+j ].buffer );
- i++;
- };
-
- return( 0 );
- }
-
- /* set_gaiji_ebg()、EBG形式の電子ブック用 */
- /* 半角 f200 */
- int set_gaiji_ebg( int code , unsigned int pagenum )
- {
- int i , j , o , k , stat , flg;
- unsigned short numofgaiji;
- unsigned char bitpatan;
- unsigned char patan[ 32 ];
-
- DOSSEEK( cdfile , pagenum*0x800 , SEEK_SET );
- DOSSEEK( cdfile , 10 , SEEK_CUR );
- DOSREAD( cdfile , &f2ascst , sizeof( unsigned short ) );
- DOSREAD( cdfile , &numofgaiji , sizeof( unsigned short ) );
-
- f2esc = ( f2ascst >> 8 );
- f2ascst = ( f2ascst & 0x00ff );
- /* 外字の終わりのコードを得る */
- f2asced = f2ascst + numofgaiji;
- if( f2asced > 255 )
- {
- f2asced = 255;
- };
- /* printf( "gaiji = %4x , %4x , %d\n" , f2ascst , f2asced , numofgaiji ); */
- f2ascmax = f2ascst-1;
- DOSSEEK( cdfile , (pagenum+1)*0x800 , SEEK_SET );
-
- /* code = JISSFT( 0x7721 ); */
- i = 0;
- for( j=f2ascst; j<=f2asced; j++ )
- {
- flg = 1;
- for( o=0; o<16; o++ )
- {
- DOSREAD( cdfile , &bitpatan , sizeof( unsigned char ) );
- patan[ o*2 ] = bitpatan;
- patan[ o*2+1 ] = 0;
- if( bitpatan != 0 )
- {
- flg = 0;
- };
- };
- if( flg == 0 )
- {
- stat = FNTGET( 8 , code , &fnttbl[ i ] );
- k = DEFCHR( 8 , code , patan );
- /* printf( "i=%x c=%4x %c%c : " , i , code , code >> 8 , code & 0x00ff ); */
- codetblebg[ j ] = code;
-
- f2ascmax++;
- code = nextcode( code );
- if( code == -1 )
- {
- flg = 1;
- puts( "外字の数が多すぎます\n" );
- };
- i++;
- } else {
- codetblebg[ j ] = 0xffff;
- };
- };
- /* printf( "gaijimax = %4x" , f2ascmax ); */
-
- return( code );
- }
-
- int reset_gaiji_ebg( void )
- {
- int i , j , stat;
-
- i = 0;
- for( j=0; j<256; j++ )
- {
- if( codetblebg[ j ] != 0xffff )
- {
- stat = DEFCHR( 8 , codetblebg[ j ] , fnttbl[ i ].buffer );
- i++;
- };
- };
-
- return( 0 );
- }
-
- /* in sjis code */
- int nextcode( int code )
- {
- code++;
- /* 0xebfd ~ 0xec3f をとばす */
- if( code == 0xebfd )
- {
- code = 0xec40;
- };
- /* 0xec7f をとばす */
- if( code == 0xec7f )
- {
- code++;
- };
- /* 外字エリアの範囲を越えた */
- if( code > 0xec9e )
- {
- code = -1;
- };
-
- return( code );
- }
-
- int nextcodejis( int code )
- {
- code++;
- if( ( code & 0x00ff ) == 0x7f )
- {
- code += (( 0x0121 - 0x007e )-1 ) ;
- };
-
- return( code );
- }
-
- /*
- void printdump( )
- {
- int i , j ;
- unsigned short data;
- int sjis;
- int ch,cl;
-
- for( i=0;i<128;i++)
- {
- printf( "%2d " , i );
- for( j=0;j<8;j++)
- {
- DOSREAD( &data , sizeof( unsigned short ) , 1 , cdfile );
- sjis = JISSFT( data );
- ch = ( sjis & 0xff00 ) >> 8;
- cl = sjis & 0x00ff ;
- printf( "%4x:%c%c " , data , ch , cl );
- };
- printf( "\n" );
- };
- }
- */